<?php
namespace App\OBService;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Mail;

class TemPlate
{
    public function created()
    {
        //使用easywechat推送模板消息
        $config = [
            'app_id' => 'wx234207019ca7c92b',//测试号app_id
            'secret' => '93870c3bc85d2a8c94387e067d7f3b4b',//测试号secret
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
        ];
        //通过 EasyWeChat 工厂类创建一个微信公众号实例
        $app = Factory::officialAccount($config);
        $res = date('Y-m-d H:i:s');
        //template_message 是 EasyWeChat 封装的微信模板消息功能的调用方法
        $app->template_message->send([
            'touser' => 'o8dsz5wUSEWv9Y7ae0XO0-AR0rA0',//用户openid
            'template_id' => 'y_NwZInYKvxh6_LGQQK2RMCuDTdZurfpYlRAAa31qyU',//发送的模板id
            'url' => 'http://www.healthcare.com/login/',//发送后用户点击跳转的链接

            $data=[
                "name"=>[
                    "value"=>"王不明",
                    "color"=>"#173177"
                ],
                "room"=>[
                    "value"=>"看病信息",
                    "color"=>"#173177"
                ],
                "set"=>[
                    "value"=>$res,
                    "color"=>"#173177"
                ]
            ]
        ]);
        return '预约已成功提交，我们会尽快与您联系';
    }
}
